package Program;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;

import agenda.Agenda;
import agenda.Meeting;
import agenda.TimerTaskExtension;

public class SynchronizedTest {
	public static void main(String[] args) {
		Agenda<Meeting> agenda1 = new Agenda<Meeting>("Frans");
		Agenda<Meeting> agenda2 = new Agenda<Meeting>("Steven");

		Timer timer1 = new Timer(false);
		Timer timer2 = new Timer(false);

		for (int i = 0; i < 10; i++) {
			TimerTaskExtension task1 = new TimerTaskExtension(agenda1, agenda2);
			TimerTaskExtension task2 = new TimerTaskExtension(agenda2, agenda1);
			long reference = Calendar.getInstance().getTimeInMillis();
			reference += 100;
			timer1.schedule(task1, new Date(reference));
			timer2.schedule(task2, new Date(reference));
		}
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		System.out.println("Done!");
		System.exit(0);
	}
}
